﻿using B.S.BasicData.Domain.XU;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Write.Api.Application.Command.Xu;
using B.S.BasicData.Write.Api.Dto;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BoxController : ControllerBase
    {
        private readonly IMediator _mediator;

        public BoxController(IMediator mediator)
        {
            _mediator = mediator;
        }

        /// <summary>
        /// 创建箱子
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateBox(CreateBoxCommad request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 显示箱子
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<BoxListDto>> BoxQuery([FromQuery] BoxQueryCommand request)
        {
            return _mediator.Send(request);
        }

       /// <summary>
       /// 删除箱子
       /// </summary>
       /// <param name="request"></param>
       /// <returns></returns>
        [HttpDelete]
        public Task<ApiResult<int>> DelBox(DelBoxCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 修改箱子
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdeteBox(UpdeteBoxCommand request)
        {
            return _mediator.Send(request);
        }
    }
}
